<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title></title>
</head>
<body>

<script type="text/javascript" src="http://libs.useso.com/js/jquery/2.1.1-rc2/jquery.min.js"></script>
<script type="text/javascript" src="js/etpl.js"></script>
<script type="text/javascript" src="js/load-template.js"></script>

<script>
    /**
     * 添加过滤器
     */
    etpl.addFilter( 'markdown', function (source, useExtra) {
        console.log(source);
        console.log(useExtra);
        return "kit";
    });
    //加载模板
    var template = loadTemplate("etpl/test.etpl");
    etpl.compile( template );
    //获取target，并渲染
    var t = etpl.render( 'myTarget' );
    $("body").append(t);
    //获取render
    var myTarget_has_sidebar = etpl.getRenderer("myTarget-has-sidebar");
    $("body").append(myTarget_has_sidebar());
    //生成匿名target 过滤器的使用
    var render = etpl.compile("<p>hello ${name|markdown(1)}</p>");
    t = render({name:"tom"});
    $("body").append(t);
    //for
    var persons={persons:[{name:"tom",email:"tom@163.com"},{name:"kite",email:"kite@163.com"}]};
    t = etpl.render("forExg",persons);
    $("body").append(t);
    //if
    t = etpl.render("ifExg",{number:1});
    $("body").append(t);
    //var的使用
    t = etpl.render("item",persons);
    $("body").append(t);

</script>
</body>
</html>